/**
 * 封装文章相关请求模块
 */
import request from '../utils/request'
import { IArticle } from './types/article'

export const getArticles = () => {
  return request.get<IArticle[]>('/posts')
}

export const getArticle = (id: IArticle['id']) => {
  return request.get<IArticle>(`/posts/${id}`)
}

export const updateArticle = (id: IArticle['id'], data: IArticle) => {
  return request.put<IArticle>(`/posts/${id}`, data)
}

export const deleteArticle = (id: IArticle['id']) => {
  return request.delete(`/posts/${id}`)
}
